package com.franklin.ideaplugin.mybatisrunner.xml;

import com.alibaba.fastjson2.annotation.JSONField;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.intellij.psi.PsiElement;
import com.intellij.psi.xml.XmlTag;
import lombok.Data;

import java.util.Map;
import java.util.Set;

/**
 * mybatis sql上下文
 *
 * @author Ye Junhui
 * @since 2024/2/20
 */
@Data
public class MybatisSqlContext {

    @JSONField(serialize = false,deserialize = false)
    private PsiElement psiElement;

    @JSONField(serialize = false,deserialize = false)
    private Integer chooseIndex = 0;

    @JSONField(serialize = false,deserialize = false)
    private Map<XmlTag,Integer> chooseIndexMap = Maps.newHashMap();

    /**
     * 测试通过
     */
    private Set<String> testCases = Sets.newLinkedHashSet();

    /**
     * 参数
     */
    private Map<String,String> paramMap = Maps.newLinkedHashMap();

    /**
     * 参数-el表达式
     */
    private Map<String,String> paramElMap = Maps.newLinkedHashMap();

    public Integer nextChooseIndex(XmlTag tag) {
        chooseIndex++;
        chooseIndexMap.put(tag, chooseIndex);
        return chooseIndex;
    }
}
